import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/view/index'
import Article from '@/view/article'
import ArticleList from '@/view/articleList'
import Classification from '@/view/classification'
import Contact from '@/view/contact'

Vue.use(Router)
//获取原型对象上的push函数
const originalPush = Router.prototype.push
//修改原型对象中的push方法
Router.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}
export default new Router({
  mode : 'hash',
  routes: [
    {path: '/',redirect: '/index'},
    {
      path: '/index',
      name: 'Index',
      meta: { requiresAuth: true },
      component: Index
    },
    {
      path: '/article',
      name: 'Article',
      component: Article 
    },
    {
      path: '/articleList',
      name: 'ArticleList',
      component: ArticleList 
    },
    {
      path: '/classification',
      name: 'Classification',
      component: Classification 
    },
    {
      path: '/contact',
      name: 'Contact',
      component: Contact 
    },
  ]
})